const App = getApp();


Page({
  data: {
    menus: [
      //  {
      //    "desc":"小区巡查",
      //    "url":"/pages/xiaoqu/index"
      //  },
      //  {
      //   "desc":"城中村巡查",
      //   "url":"/pages/chengzhongcun/index"
      // },
      //  {
      //   "desc":"城中村",
      //   "url":"/pages/qu/index"
      // },
      // // {
      // //   "desc":"城中村附件",
      // //   "url":"/pages/chengzhongcun_fujian/index"
      // // },
      // {
      //   "desc":"水厂巡查",
      //   "url":"/pages/shuichang/index"
      // },
      // {
      //   "desc":"水库巡查",
      //   "url":"/pages/shuiku/index"
      // }
    ]
  },
  tourl(e) {
    console.log(e)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let _this = this
    let userid = wx.getStorageSync('user_id');
    console.log(userid)
    if (userid) {
      console.log('已登陆')
    } else {
      wx.navigateTo({
        url: '/pages/login/login',
      })
    }
  },
  onShow() {
    let userid = wx.getStorageSync('user_id');
    console.log(userid)
    if (userid) {
      console.log('已登陆')
      let hasFubiaoPromission = wx.getStorageSync('hasFubiaoPromission')
      let hasZhuBiaoPromission = wx.getStorageSync('hasZhuBiaoPromission')
      console.log('hasFubiaoPromission', hasFubiaoPromission)
      console.log('hasZhuBiaoPromission', hasZhuBiaoPromission)
      if (hasFubiaoPromission || hasZhuBiaoPromission) {
        this.setData({
          menus: [
            {
              "desc": "全市城中村",
              "url": "/pages/qu/index"
            },
          ]
        })
      } else {
        this.setData({
          menus: [
            {
              "desc": "小区巡查",
              "url": "/pages/xiaoqu/index"
            },
            {
              "desc": "城中村巡查",
              "url": "/pages/chengzhongcun/index"
            },
            {
              "desc": "水厂巡查",
              "url": "/pages/shuichang/index"
            },
            {
              "desc": "水库巡查",
              "url": "/pages/shuiku/index"
            }
          ]
        })
      }
    }
    },
    /**
     * 分享当前页面
     */
    onShareAppMessage() {
      let _this = this;
      return {
        title: '供水巡查',
        path: `/pages/index/idnex`,
      };
    },
    onShareAppMessage() {
      let _this = this;
      return {
        title: '供水巡查',
        path: "/pages/index/index"
      };
    }

  });